package com.lbx.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.lbx.entity.User;
import com.lbx.utils.JsonUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @author 吕兵星
 * @date 2020/10/23 11:52
 */
@Controller
public class HelloController {
    @ResponseBody
    @GetMapping(value = "/h1" ,produces = "application/json;charset=utf-8")
    public String hello() throws JsonProcessingException {
        User user = new User("吕冰星",11,"男");
        return JsonUtils.getJson(user);
    }
    @ResponseBody
    @GetMapping(value = "/h2" ,produces = "application/json;charset=utf-8")
    public String hello1() throws JsonProcessingException {
        Date date = new Date();
        return JsonUtils.getJson(date,"yyyy-MM-dd HH:mm:ss");
    }
}
